package com.briup.srms.sms.web.controller;

import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.srms.sms.bean.EmployeeEvent;
import com.briup.srms.sms.bean.extend.EmployeeEventExtend;
import com.briup.srms.sms.service.IEmployeeEventService;
import com.jacky.base.utils.Message;
import com.jacky.base.utils.MessageUtil;
import com.jacky.base.utils.PageVM;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * @program: sms
 * @description: 员工事件控制器类
 * @author: jacky
 * @create: 2021-1-5 14:41
 **/
@Api(description="企业员工事件相关接口")
@Validated
@RestController
@RequestMapping("/employeeEvent")
public class EmployeeEventController {

	@Autowired
	private IEmployeeEventService employeeService;

	@ApiOperation(value = "分页多条件获取员工事件信息")
	@GetMapping("pageQuery")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "page", value = "当前页", required = true, paramType = "query"),
		@ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, paramType = "query"),
		@ApiImplicitParam(name = "employeeId", value = "员工事件编号", paramType = "query"),
		@ApiImplicitParam(name = "event", value = "事件类型", paramType = "query"),
		@ApiImplicitParam(name = "clazzId", value = "班级编号", paramType = "query"),
	})
	public Message pageQuery(int page, int pageSize,Long employeeId,String event,Long clazzId) {
        System.out.println("【pageQueryEmployeeEvent】");
		PageVM<EmployeeEventExtend> pageVM = employeeService.pageQuery(page, pageSize,employeeId,event,clazzId);
		return MessageUtil.success(pageVM);
	}

	@ApiOperation(value = "通过id删除员工事件信息")
	@GetMapping("deleteById")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "id", value = "编号", required = true, paramType = "query"),
	})
	public Message deleteById(@NotNull long id) {
		employeeService.deleteById(id);
		return MessageUtil.success("删除成功!");
	}

	// 未用到
	@ApiOperation(value = "保存或更新班主任信息")
	@PostMapping("saveOrUpdate")
	public Message saveOrUpdate(EmployeeEvent employee) {
		// 教管部班主任角色编号
		long roleId = 8l;
		employeeService.saveOrUpdate(employee,roleId);
		return MessageUtil.success("操作成功！");
	}
}
